//
//  MSCreateDatabaseVC.m
//  MinShengBank
//
//  Created by chen wei on 13-10-14.
//  Copyright (c) 2013年 Hq. All rights reserved.
//

#import "MSCreateDatabaseVC.h"


@implementation MSCreateDatabaseVC
static MSCreateDatabaseVC* _instance;

+ (MSCreateDatabaseVC *)instance {
    if (nil == _instance) {
		_instance = [[MSCreateDatabaseVC alloc] init];
	}
	return _instance;
}

- (void)doCreateTable
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *sqliteName = [NSString stringWithFormat:@"%@.sqlite3", [defaults objectForKey:@"userId"]];
    [defaults setObject:sqliteName forKey:@"CurrentDataBaseName"];
    DB = [[SQLite alloc] initWithDbName:[defaults objectForKey:@"CurrentDataBaseName"]];

    
    //附件表
    if(![DB createTable:@"CREATE TABLE IF NOT EXISTS attachmentTable(testId INTEGER PRIMARY KEY autoincrement,userId  TEXT,parentId TEXT,localpath  TEXT,serverpath TEXT,filename  TEXT,filetype  TEXT,filesize  TEXT,createtime  TEXT);"]){NSLog(@"建库失败");};
    

    
    //公告通知
    if (! [DB createTable:@"CREATE TABLE IF NOT EXISTS AnnounceRecordsTable(AnnounceRecordId INTEGER PRIMARY KEY autoincrement,id  TEXT,title  TEXT,context  TEXT,closeTime TEXT,createUser  TEXT,createDate  TEXT,upDatetime TEXT,files TEXT);"]) {
        NSLog(@"建库失败");
    }
    
    //公告通知
    if (! [DB createTable:@"CREATE TABLE IF NOT EXISTS huiyi(AnnounceRecordId INTEGER PRIMARY KEY autoincrement,id  TEXT,title  TEXT,context  TEXT,closeTime TEXT,createUser  TEXT,createDate  TEXT,upDatetime TEXT,files TEXT);"]) {
        NSLog(@"建库失败");
    }
   
}
@end
